home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Archives / ForCLI / HeadTail11.readme < prev    next >
Text File  |  1996-09-26  |  5KB  |  137 lines

  1. Short:    Show first/last n lines/chars of a file.
  2. Author:   D. Chapman/Dan Cannon <dan@blender.demon.co.uk>
  3. Uploader: Dan Cannon <dan@blender.demon.co.uk>
  4. Type:     util/cli
  5.  
  6. This is an update to headtail.lha, written by D. Chapman. It was going wrong
  7. sometimes, I changed it to work with longer lines. While I was at it, I made
  8. it so that the file name can be case insensitive (eg. you can call it head,
  9. Head, tail, TAIL, etc...) because it checks its own file name to work out
  10. whether you want head or tail.
  11.  
  12. Anyway, copy HeadTail to C:Head and C:Tail and you're sorted.
  13.  
  14. Dan.
  15.  
  16. ----- Original Read Me -----
  17.  
  18. Short: unix-style head/tail, better than others
  19.  
  20. Well, yes, they are, to be honest.  I haven't yet seen a "head" or
  21. "tail" program for AmigaDOS which even implemented the lbc stuff in
  22. the "real" tail for Unix.  Though numerous, all the tails I've seen
  23. can only do lines, with one exception that could do chars.  This last,
  24. however, couldn't read from standard input.  I found my work severely
  25. limited; I maintain that head and tail are among the most useful tools
  26. in the unix environment.
  27.  
  28. So here's a tail program that reads any number of files, or standard
  29. input; if more than one file is read, the start of each file is noted
  30. in stderr, with files sections themselves going to stdout.  Unlike
  31. most other Amiga tails I've seen, headtail can do head-relative or
  32. tail-relative tailing by using "+" or "-" before the count.  E.g., for
  33. the file:
  34.  
  35. Start
  36. Line1
  37. Line2
  38.  
  39. Line4
  40. End
  41.  
  42. > tail +3l <file>
  43.  
  44. would report:
  45. Line2
  46.  
  47. Line4
  48. End
  49.  
  50. while
  51.  
  52. > tail -3l <file>
  53.  
  54. would report:
  55.  
  56. Line4
  57. End
  58.  
  59. You see?
  60.  
  61. Character units (specifiec with "c" in place of "l") work similarly;
  62.  
  63. > tail -7 <file>
  64.  
  65. on the above example file would return:
  66. e4
  67. End
  68.  
  69. (You must remember to count line feeds.)
  70.  
  71. Blocks work the same way; a block is equivalent to 512 characters.
  72. You can change this in the source code to 488 if you use an OFS
  73. system; it will more accurately reflect your actual file structure.
  74.  
  75.  
  76.  
  77. AND, AS AN ADDED BONUS:
  78.  
  79. The Unix "head" is included, too.  Soaring above even Unix head,
  80. however, headtail's head will take all the same arguments as tail.
  81. The only difference in meaning is that "+" and "-" swap places; i.e,
  82.  
  83. Program    Sign    Meaning
  84. tail    +    count is relative to start of file
  85. tail    -    count is relative to end of file
  86. head    +    count is relative to end of file
  87. head    -    count is relative to start of file
  88.  
  89. Thus Unix-formatted commands work with headtail, but there are more
  90. option if you want them.
  91.  
  92.  
  93.  
  94. BUT WAIT -- THERE'S EVEN MORE!
  95.  
  96. As a special for Kickstart v36+ users, head and tail are included as
  97. one program.  It works like compress: there's one program, and its
  98. function is determined by its name.  Basic installation consists of
  99. copying tail to somewhere in your path, and making a link from "head"
  100. to "tail".  (You could, of course, do it the other way.)  If called as
  101. "head", the program performs head stuff; if called as "tail", it does
  102. tail stuff.  If called something else, it still does tail stuff.
  103.  
  104. If you don't have 2.0, you should.  But you can still use headtail by
  105. just copying the program to "head", then to "tail".  They don't have
  106. to be links, but it saves disk space if they are.
  107.  
  108.  
  109.  
  110. HeadTail was written by David Champion some time in July - August
  111. 1992.  It was compiled with Matt Dillon's DICE, and the source code is
  112. geared toward that compiler.  SAS users will have to perform surgery
  113. to make it work, I know.  I tried and gave up becasue I hate SAS
  114. anyway.  Aztec users might have to do cosmetic stuff.  GCC works fine;
  115. just be sure you've either #defined of -D-defined GCC.
  116.  
  117. This stuff, binary and source, is public domain.  I release all
  118. liability for damages brought about by usage at just the wrong time of
  119. day in La Paz, or whatever else could cause a problem, along with
  120. rights to the code.  It's everyone's now.
  121.  
  122.  
  123. ============================= Archive contents =============================
  124.  
  125. Original  Packed Ratio    Date     Time    Name
  126. -------- ------- ----- --------- --------  -------------
  127.      628     259 58.7% 16-Jul-95 15:44:00  HeadTail11.info
  128.      628     264 57.9% 16-Jul-95 15:44:00 +C.info
  129.    11120    7100 36.1% 16-Jul-95 15:44:00 +HeadTail
  130.     3825    1937 49.3% 16-Jul-95 15:44:00 +ReadMe
  131.      463     237 48.8% 16-Jul-95 15:44:00 +ReadMe.info
  132.      628     269 57.1% 16-Jul-95 15:44:00 +Source.info
  133.     4697    2045 56.4% 16-Jul-95 15:44:00 +headtail.c
  134.      172     107 37.7% 16-Jul-95 15:44:00 +Makefile
  135. -------- ------- ----- --------- --------
  136.    22161   12218 44.8% 16-Jul-95 22:18:54   8 files
  137.